package com.fr.chart.core.glyph;

import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.chart.core.FoldLine;
import com.fr.chart.core.Glyph;
import java.awt.Graphics;
import java.awt.Shape;
import java.awt.geom.Area;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CompositeGlyph
  implements Glyph
{
  private static final long serialVersionUID = -8132349394753019294L;
  public static final String XML_TAG = "CompositeGlyph";
  private List children = new ArrayList();

  public void draw(Graphics paramGraphics)
  {
    for (int i = 0; i < size(); ++i)
      get(i).draw(paramGraphics);
  }

  public Shape getShape()
  {
    Area localArea = new Area();
    for (int i = 0; i < size(); ++i)
      localArea.add(new Area(get(i).getShape()));
    return localArea;
  }

  public Iterator selectableChildren()
  {
    return getChildren().iterator();
  }

  public Glyph get(int paramInt)
  {
    return ((Glyph)getChildren().get(paramInt));
  }

  public void add(Glyph paramGlyph)
  {
    getChildren().add(paramGlyph);
  }

  public Glyph remove(int paramInt)
  {
    return ((Glyph)getChildren().remove(paramInt));
  }

  public boolean remove(Glyph paramGlyph)
  {
    return getChildren().remove(paramGlyph);
  }

  public void setChildren(List paramList)
  {
    this.children = paramList;
  }

  public List getChildren()
  {
    return this.children;
  }

  public int size()
  {
    return getChildren().size();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    CompositeGlyph localCompositeGlyph = (CompositeGlyph)super.clone();
    return localCompositeGlyph;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
    {
      String str = paramXMLableReader.getTagName();
      if (str.equals("FoldLine"))
        add((FoldLine)paramXMLableReader.readXMLObject(new FoldLine()));
      else if (str.equals("ShapeGlyph"))
        add((ShapeGlyph)paramXMLableReader.readXMLObject(new ShapeGlyph()));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    int i;
    paramXMLPrintWriter.startTAG("CompositeGlyph");
    if ((this.children != null) && (getChildren().size() > 0))
      for (i = 0; i < this.children.size(); ++i)
        ((Glyph)this.children.get(i)).writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof CompositeGlyph))
      return false;
    CompositeGlyph localCompositeGlyph = (CompositeGlyph)paramObject;
    if (localCompositeGlyph.getChildren() != null)
    {
      if (getChildren() == null)
        break label103;
      if (localCompositeGlyph.getChildren().size() != getChildren().size())
        return false;
      int i = 0;
      while (true)
      {
        if (i >= localCompositeGlyph.getChildren().size())
          break label103;
        Glyph localGlyph = localCompositeGlyph.get(i);
        if (!(localGlyph.equals(get(i))))
          return false;
        ++i;
      }
    }
    label103: return (getChildren() == null);
  }

  public JSONObject toJSONObject()
    throws JSONException
  {
    return null;
  }
}